Unity 5.x Animation Cookbook by 2016

Unity 5.x Animation Cookbook by 2016

Author:2016
Language: eng
Format: mobi, epub
Publisher: Packt Publishing


Place our character in the scene and assign the controller to its Animator component.

Add a Bird tag to the character. We will use the tag in the following script.

Create a new script and call it FlockDecoration.cs.

In this script, we first find all the game objects with the Bird tag and store them in the GameObject[] birds array. We do it in the Start() function. In the Update() function, when the player presses the space bar, we set the bool Fly parameter in our controller to its inverted value (if it was true, we set it to false, and vice versa). We do it for every bird stored in the birds array: for (int i = 0; i < birds.Length; i++) { Animator anim = birds[i].GetComponent<Animator>(); anim.SetBool("Fly", !anim.GetBool("Fly")); }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.